<?php

namespace pmvc\data\transform;

/**
 * An implementation of the {@link Transformer}
 * interface that uses a provided closure to
 * transform values.
 */
class ClosureTransformer
	implements Transformer {

	private $fun = null;

	/**
	 * Creates the {@link Transformer} with the
	 * given closure.
	 * @param callback $fun
	 */
	public function __construct($fun) {
		$this->fun = $fun;
	}

	/**
	 * {@inheritDoc}
	 * @see pmvc\data\transform.Transformer::transform()
	 */
	public function transform($input) {
		$fun = $this->fun;
		return $fun($input);
	}

}

?>